//
// helloworld.cc
//

#include "helloworld.h"


static gboolean  f_on_window_delete_event(GtkWidget *widget, GdkEvent *p_event, gpointer p_data)
{
    gtk_main_quit();
    return FALSE;
}

static void  f_on_button_clicked(GtkButton *p_button, gpointer p_data)
{
    g_print("Hello World\n");
}

void  f_create_main_win(void)
{
    GtkBuilder *p_gtk_builder = gtk_builder_new();
    if(g_file_test("img/helloworld.glade", G_FILE_TEST_EXISTS))
        gtk_builder_add_from_file(p_gtk_builder, "img/helloworld.glade", NULL);
    else
        gtk_builder_add_from_file(p_gtk_builder, DATADIR "/helloworld/helloworld.glade", NULL);
    
    GtkWidget *p_window = GTK_WIDGET(gtk_builder_get_object(p_gtk_builder, "window"));
    GtkWidget *p_button = GTK_WIDGET(gtk_builder_get_object(p_gtk_builder, "button"));
    
    g_signal_connect(p_window, "delete-event", G_CALLBACK(f_on_window_delete_event), NULL);
    g_signal_connect(p_button, "clicked", G_CALLBACK(f_on_button_clicked), NULL);
    
    gtk_widget_show_all(p_window);
}
